package com.count.rule;

import com.count.number.SpecialNumber;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZhongGang
 * Date: 14-5-4
 * Time: 下午2:51
 */
public class ContainMultipleSpecialNumberRule implements SpecialNumberRule {

    @Override
    public String count(Integer number, List<SpecialNumber> specialNumbers) {
        Integer containedCount = 0;
        String result = "";
        for (SpecialNumber specialNumber : specialNumbers) {
            if (number % specialNumber.getNumber() == 0) {
                containedCount += 1;
                result += specialNumber.getWord();
            }
        }
        if (containedCount > 1) {
            return result;
        }

        return null;
    }
}
